﻿using Sustainalytics.Entities;
using Sustainalytics.Portfolios.Service.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PortfolioBase = Sustainalytics.Portfolios.Service.Models.PortfolioBase;

namespace Sustainalytics.Universes.Service.Models
{
    public class PortfolioUniverseMixDto
    {
        public Guid Id { get; set; }
        public string Name { get; set; }
        public bool IsPortfolio { get; set; }


        //public Guid AddedByUserId { get; set; }
        //public string AddedByUserName { get; set; }
        //public string AddedByFullName { get; set; }
        //public int CompanyCount { get; set; }
        //public bool IsMyPortfolio { get; set; }        

        //public PortfolioSharingStatus SharingStatus { get; set; }
        //public DateTime DataCreated { get; set; }    //Equivalent for Universe  "Created" field
        //public DateTime? DateModified { get; set; }   //Equivalent for Universe  "Last Updated" field
           
        //Universe part
        public Guid AccountId;

        public int universeId { get; set; }

        public static List<PortfolioUniverseMixDto> ConvertToMixListFromPortfolioDtos(List<PortfolioBase> portfolioDtoList)
        {
            return (from PortfolioBaseDto portfolioItem in portfolioDtoList
                select new PortfolioUniverseMixDto()
                {
                    Id = portfolioItem.Id, Name = portfolioItem.Name, IsPortfolio = true,

                    //AddedByFullName = portfolioItem.AddedByFullName,
                    //AddedByUserName = portfolioItem.AddedByUserName,
                    //AddedByUserId = portfolioItem.AddedByUserId,
                    //CompanyCount = portfolioItem.CompanyCount,
                    //DataCreated = portfolioItem.DataCreated,
                    //DateModified = portfolioItem.DateModified,
                    //IsMyPortfolio = portfolioItem.IsMyPortfolio,                   
                    //SharingStatus = portfolioItem.SharingStatus
                }).ToList();
        }

        public static List<PortfolioUniverseMixDto> ConvertToMixListFromUniversesDtos(List<UniverseDto> universesDtoList)
        {
            List<PortfolioUniverseMixDto> universesPortfoliosMixDtos = new List<PortfolioUniverseMixDto>();

            foreach (UniverseDto universeItem in universesDtoList)
            {              
              
                PortfolioUniverseMixDto mixDto = new PortfolioUniverseMixDto()
                {
                    //Id = guidRes,
                    universeId  = universeItem.Id,
                    IsPortfolio = false,
                    AccountId = universeItem.AccountId,            
                    //DataCreated = universeItem.Created,
                    //DateModified = universeItem.LastUpdated,                    
                    Name = universeItem.Name,                    
                };

                universesPortfoliosMixDtos.Add(mixDto);
            }
            return universesPortfoliosMixDtos;
        }
    }
}
